#!/bin/bash
#
#更新GIT到最新版本
#
echo "开始执行"
CMD_PATH=`dirname $0`
cd $CMD_PATH
echo "进入目录：$PWD"
cd ../

WEB_USER='www'
WEB_USERGROUP='www'

#
# 未clone请先做一下clone
# 如git clone git@git.oschina.net:suncco/haicang.git /home/www/haicang-git-master
#
echo pwd
echo "拉取代码..."
git reset --hard HEAD
git clean -f
git pull

#处理数据库配置被覆盖
rm -rf ./config/database.php
cp -rf ./config/database.master.php ./config/database.php
echo "修改目录用户权限..."

rm -rf ./runtime/*

chmod -R 755 ./shell/git-update.sh
chmod -R 755 ./runtime

chown -R $WEB_USER:$WEB_USERGROUP ./runtime

echo "完成！！！"
